<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2022/10/31
  Time: 9:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>个人中心</title>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/personal_center.css">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/css/head_daohang.css">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
  <script src="${pageContext.request.contextPath}/js/jquery-3.6.0.min.js"></script>
</head>
<body>
<!-- 主要布局范围 -->
<div class="main">
  <!-- 头部导航栏 -->
  <div id="head">
    <div class="layui-col-md2">
      <div class="grid-demo ">
        <div class="head-logo"></div>
      </div>
    </div>
    <div class="layui-col-md2">
      <div class="grid-demo head-demo"><a href="${pageContext.request.contextPath}/index.jsp" class="word-1">首页</a></div>
    </div>
    <div class="layui-col-md2">
      <div class="grid-demo head-demo"><a href="${pageContext.request.contextPath}/car/getCarView" class="head-hover word-1">自驾租车</a>
      </div>
    </div>
    <%--    <div class="layui-col-md1">--%>
    <%--        <div class="grid-demo head-demo"><a href="${pageContext.request.contextPath}/long_time_older/long_time.jsp" class="head-hover word-1">长租专区</a>--%>
    <%--        </div>--%>
    <%--    </div>--%>
    <div class="layui-col-md2">
      <div class="grid-demo head-demo"><a href=" ${pageContext.request.contextPath}/carOutlets/carAllList" class="head-hover word-1">车型查询</a>
      </div>
    </div>
    <div class="layui-col-md2">
      <div class="grid-demo head-demo"><a href="${pageContext.request.contextPath}/Offline_outlets/Business_outlets.jsp" class="head-hover word-1">营业网点</a></div>
    </div>
    <%--    <div class="layui-col-md1">--%>
    <%--        <div class="grid-demo head-demo"><a href="" class="head-hover word-1">会员专区</a></div>--%>
    <%--    </div>--%>
    <div class="layui-col-md2">
      <div class="grid-demo head-demo1">
        <i class="login-icon"></i>
        <a href="${pageContext.request.contextPath}/login/login.jsp" class="head-color">登录/注册</a>
      </div>
      <div class="tel">
        <i class="tel-icon"></i>
        <span class="tel-num">110-119-1111</span>
      </div>
    </div>
  </div>
  <!-- 面包屑 -->
  <div class="crumbs">
    <div class="crumbs-bd">当前位置: <a href="${pageContext.request.contextPath}/customer/getId/${cust.custId}" class="crumbs-person">个人中心</a> > </div>
  </div>
  <!-- 主要内容 -->
  <div class="content">
    <div class="content-bd">
      <!-- 左侧导航栏 -->
      <div class="col-sub">
        <ul>
          <div class="title">订单信息</div>
          <li class="text"><a href=javascript:getMyAllOrders()>我的订单</a></li>
          <%--                    <li class="text"><a href="${pageContext.request.contextPath}/customer/personalCenter-OtherOrler.jsp">他人代订</a></li>--%>
          <%--                    <div class="title">会员信息</div>--%>
          <%--                    <li class="text"><a href="">会员优惠</a></li>--%>
          <%--                    <li class="text"><a href="">会员特权</a></li>--%>
          <%--                    <li class="text"><a href="">会员积分</a></li>--%>
          <div class="title">我的钱包</div>
          <%--                    <li class="text"><a href="${pageContext.request.contextPath}/customer/personalCenter-AccountBalance.jsp">账户余额</a></li>--%>
          <%--                    <li class="text"><a href="${pageContext.request.contextPath}/customer/personalCenter-Voucher.jsp">我的代金卷</a></li>--%>
          <li class="text"><a href="javascript:method1()" class="mycoupon">我的优惠编码</a></li>
          <div class="title">车辆喜好</div>
          <li class="text"><a href="" id="hotCar">车辆推荐</a></li>
          <div class="title">个人资料</div>
          <li class="text"><a href="" class="customMessage">用户信息</a></li>
          <li class="text"  onclick="return confirm('即将返回登录界面，确定吗？');"><a href="${pageContext.request.contextPath}/login/login.jsp" class="exit-token">账户注销</a></li>
        </ul>
      </div>
      <!-- 主要信息栏 -->
      <div class="col-main">
        <div class="Code-biaoti">用户信息</div>
        <div class="user-img"><img src="${pageContext.request.contextPath}/images/headpicture.png" alt=""></div>
        <form class="user-message" method="post" action="/wy_car_rental/customer/getId/${customer.custId}/get_info/save">

          <div class="info"><span style="color: red">*</span><b>电子邮件：</b><input type="text" name="addEmail" class="addEmail" value="${customer.custEmail}"/></div>
          <div class="info"><span style="color: red">*</span><b>手机号码：</b><input type="text" name="addTel" class="addTel" value="${customer.custTelno}"/></div>
          <div class="info"><span style="color: red">*</span><b>姓名：</b><input type="text"  name="addName" class="addName" value="${customer.custName}"/></div>
          <div class="info"><span style="color: red">*</span><b>证件类型：</b> <select id="Cer-se" name="addCertificates" >
                <option id="shenfen"  value="1">- - - - -身份证- - - - -</option>
                <option id="huzhao"   value="2">- - - - -护照- - - - -</option>
          </select>
            <input type="hidden" id="cust-Cer" value="${customer.custCertificates}">
            </div>
          <div class="info"><span style="color: red">*</span><b>证件号码：</b><input type="text" name="addCertificatesNumber" class="addCertificatesNumber" value="${customer.custCertificatesNumber}"/></div>
          <div class="info"><span style="color: red">*</span><b>出生日期：</b><input type="text" name="addBir" class="addBir" value="${customer.custBirthday}"/></div>
          <div class="info"><span style="color: red">*</span><b>驾驶认证：</b><input type="text" name="addDrive" class="addDrive" value="${customer.custDriverLicense}"/></div>
          <input type="submit" class="BTN" value="保存" >
        </form>
        `<span class="saveMsg"></span>
          <input type="hidden" id="custId" value="${customer.custId}">
        <input type="hidden" id="custName" value="${customer.custName}">
      </div>
    </div>
  </div>
  <!-- 尾部 -->
  <div class="footer">
    <div class="footer-box">
      <div class="footer-left">
        <p>
          <span>关于无忧</span> |
          <span>移动客户端</span> |
          <span>帮助中心</span> |
          <span>建议专区</span> |
          <span>联系我们</span> |
          <span>友情连接</span> |
          <span>投诉通道：400-821-1608</span>
        </p>
        <p>
          <span>Copyright © 2007-2022 苏州无忧信息技术服务有限公司 ICP证：苏B2-20140130|苏ICP备08010394号-1</span>
        </p>
      </div>
      <div class="footer-right"></div>
    </div>
  </div>
</div>
<script>
  // 查询我的所有订单
  function getMyAllOrders(){
    var token = localStorage.getItem("token");
    location.href="${pageContext.request.contextPath}/orders/getOrdersByCustomerId/"+token;
  }

  function  method1() {
    console.log("点击")
    var token  = localStorage.getItem("token");
    location.href="${pageContext.request.contextPath}/customercoupon/getall?token="+token;
    // $(".mycoupon").attr("href","customercoupon/getall?token="+token);

  }

  $(document).ready(function () {
    var se = $("#cust-Cer").val();
    $("#Cer-se").val(se);
  loadInitData();
  function loadInitData() {
    console.log("00000000000000")
    var token = localStorage.getItem("token");
    // ----->cpmtollrt toke 你=-----
    console.log("token-----:" + token)
    $.ajax({
      type: "get",
      url: "${pageContext.request.contextPath}/customer/personalData",
      headers: {"token": token},
      success: function (result) {
        console.log(result);
        var loginUser = result.data.loginCustomer;
        var loginUserName = result.data.customerName;

        if(loginUser != null) {
          $(".head-color").text(loginUserName);
          $(".head-color").attr("href", "");
          $(".crumbs-person").attr("href","${pageContext.request.contextPath}/customer/getId/" + loginUser.custId)
          $("#hotCar").attr("href","${pageContext.request.contextPath}/recommendByUser?custId=" + loginUser.custId + "&num=5")

        }else{
          console.log("2222222")
          $(".head-color").text("登录");
          $(".head-color").attr("href", "login/login.jsp");
        }
      }
    })
  }
  })
    $(".BTN").click(function (){
      var formData = $(".user-message").serialize();
      if(formData!=null)
        $(".saveMsg").text("保存成功");
      else
        $(".saveMsg").text("保存失败");
      console.log(formData);
      $.ajax({
        type:"post",
        url:"customer/getId/${customer.custId}/get_info/save",
        dataType:"json",
        data: formData,
        headers: {"token": token}
      })
    })




   //        $(".addEmail").val(customer.custEmail);
   //        $(".addTel").val(customer.custTelno);
   //        $(".addName").val(customer.custName);
   //        $(".addCertificatesNumber").val(customer.custCertificatesNumber);
   //        $(".addBir").val(customer.custBirthday);
   //        $(".addDrive").val(customer.custDriverLicense);
   //        let select = customer.custCertificates == 1 ? $("#shenfen") : $("#huzhao");
   //        select.prop("selected","selected");
   //
   //    })



</script>
</body>

</html>
